<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="/wondershare/js/jquery.js"></script> 
<script src="/wondershare/js/jquery.cvbox.min.js"></script> 
<link href="/wondershare/styles/main.css" rel="stylesheet" type="text/css" />
<link href="/wondershare/styles/general.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../images/unti.js"></script>
<title>文字广告<{$title}>页</title>
<script>


function getproductslist(type)
 {
	var w_type = $("#w_type").val();
    var ad_id = $("#ad_id").val();
    var products_position = $("#products_position").val();
   if(type == 'products_list')
   {
	
	 jIframe('', '文字选择产品列表', {
				width: 750,
				height: 345,
				src: './ad_text.php?action=products_list&w_type='+w_type+'&products_position='+products_position+'&ad_id='+ad_id,
				ID: 'all_ws_products',
				box_btn:true,
                callback:add_products
			});
   }
   
 }
 
function add_products()
{
 	var checked_ws_id = document.getElementById("all_ws_products").contentWindow.get_checked_value();
	var checked_products_name = document.getElementById("all_ws_products").contentWindow.get_checked_products_value();
    $("#products_data").val(checked_products_name);
	$("#products_position").val(checked_ws_id);
	 jClose();
}
 
function  is_name_exist()
{
  $.get("http://cms.wondershare.com.br.wx/wondershare/ad_text.php?action=add_edit&w_type=<{$w_type}>", 
  {ad_name: $("#ad_name").val(),act: 'is_name_exist',ad_id:$("#ad_id").val()}, function(data)
  {
	 if(data >0)
	{
		 alert('广告名称已经存在库中，请重新录入！');
		$("#ad_name").val('');
		return false;
	}
 });
}
$(document).ready(function(){

  $("#ad_name").blur(function() {
     is_name_exist();
      
  });
  $("#ad_content").keyup(function(){   
	if($("#ad_content").val().length > 200)
	{
	   $("#ad_content").val($("#ad_content").val().substring(0,200) );
	}
	});
  
}); 
function check_submit()
{
  if($('#ad_name').val().replace(/(^\s*)|(\s*$)/g, "")=="")
  {
      alert('文字广告名称不能为空！');
      $("#ad_name").focus();
      return false;
  }
	if($('#ad_url').val().replace(/(^\s*)|(\s*$)/g, "")!="")
   {
		str = $('#ad_url').val().match(/http:\/\/.+/); 
		if (str == null){
			alert('你输入文字广告链接URL无效');
			$("#ad_url").focus(); 
			return false;
		}
	}
	
  return true;
}
</script>
</head>
<body>
<h1>
<span class="action-span1">
<a href="http://cms.wondershare.com.br.wx/wondershare/ad_text.php?action=index&w_type=<{$w_type}>"><{$web_info}>文字广告管理</a>
</span> 
<span id="search_id" class="action-span1"> > <{$title}>广告</span>
<div style="clear:both"></div>
</h1>
<div id="tabbody-div"  style=" width:1100px;">
      <form  name="theForm" method="post" action="/wondershare/ad_text.php?action=add_edit&w_type=<{$w_type}>" onsubmit="return check_submit();">
        <table align="center" width="90%" id="general-table">
          <tbody>
		  <tr>
            <td class="label">*文字广告名称：</td>
            <td><input type="text" size="60" style="float:left;color:;" value="<{$ad_info.ad_name}>" name="ad_name" id="ad_name"> </td>
          </tr>
		  <tr>
            <td class="label">文字广告链接：</td>
            <td><input type="text" size="60" style="float:left;color:;" value="<{$ad_info.ad_url}>" name="ad_url" id="ad_url">
            </td>
          </tr>
		  <tr>
            <td class="label">文字广告内容：</td>
  			<td>
			  <textarea cols="60" rows="6" id="ad_content" name="ad_content"><{$ad_info.ad_content}></textarea> <span style="color:#FF0000">限制字数200个</span>
             </td>
          </tr>   
		  <tr>
            <td class="label">文字广告投放产品位置：</td>
  			<td>
			 <textarea cols="60" rows="6" id="products_data" name="products_data"  disabled="disabled" wrap="on" ><{$ad_info.product_name_str}></textarea>
			 <input type="hidden" name="products_position"  id="products_position" value="<{$ad_info.product_id_str}>" />
			 <input type="hidden" name="start_products_position"  id="start_products_position" value="<{$ad_info.product_id_str}>" />
			 <input type="button" value="选择投放"  name="get_products"  style="margin-left:20px; margin-top:10px; " onclick="getproductslist('products_list');"  />
             </td>
          </tr>      
        </tbody></table>
        <div  style="margin-left:380px; margin-top:20px;">
          <input type="hidden"  name="ad_id" id="ad_id" value="<{$ad_info.ad_id}>">
	      <input type="hidden"  id="w_type" name="w_type" value="<{$w_type}>" >
          <input type="submit"   class="button" value=" <{$title}> " name="sub_from">
          <input type="reset" class="button" value=" 重置 ">
        </div>
        <input type="hidden" value="<{$form_act}>" name="act" >
      </form>
    </div>
</body>
</html>